package cn.kgc.jdbc;

import cn.kgc.utils.JDBCUtil;
import jdk.nashorn.internal.scripts.JD;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author mosin
 * date 2022/2/11
 * @version 1.0
 *
 */
public class JDBCDemo04 {

    public static void main(String[] args) {

        Connection connection = JDBCUtil.getConnection();
        PreparedStatement pstmt = null;
        String sql = "delete from usr where id = ?";
        try {
             pstmt = connection.prepareStatement(sql);
            pstmt.setInt(1, 2);
            int i = pstmt.executeUpdate();
            System.out.println("line = " + i);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.closeAll(null, pstmt, connection);
        }

    }
}
